projects
/
project
/
luci.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
07f0574
)
luci-base: rpcd: handle swap entries in getBlockDevices
author
Jo-Philipp Wich
<
[email protected]
>
Fri, 28 Apr 2023 13:04:43 +0000
(15:04 +0200)
committer
Jo-Philipp Wich
<
[email protected]
>
Fri, 28 Apr 2023 13:04:43 +0000
(15:04 +0200)
Add entries from `/proc/swaps` to the result array as well in order to
let the ui properly deal with swap files.
Fixes: #6350
Signed-off-by: Jo-Philipp Wich <
[email protected]
>
(backported from commit
ad3509bf3bb5dfa79af634c841d584408068fb0a
)
modules/luci-base/root/usr/libexec/rpcd/luci
patch
|
blob
|
history
diff --git
a/modules/luci-base/root/usr/libexec/rpcd/luci
b/modules/luci-base/root/usr/libexec/rpcd/luci
index f124512f59a1bfd43e6ac56fcb836d61e6e75958..7ce59a3a842299082b69ecb2b21d37e2ddff44c4 100755
(executable)
--- a/
modules/luci-base/root/usr/libexec/rpcd/luci
+++ b/
modules/luci-base/root/usr/libexec/rpcd/luci
@@
-488,6
+488,30
@@
local methods = {
block:close()
+ local swaps = io.open("/proc/swaps", "r")
+ if swaps then
+ while true do
+ local ln = swaps:read("*l")
+ if not ln then
+ break
+ end
+
+ local dev, s = ln:match("^(/%S+)%s+%S+%s+(%d+)")
+ if dev and s then
+ rv["swap:" .. dev] = {
+ dev = dev:gsub("\\(%d%d%d)",
+ function(n)
+ return string.char(tonumber(n, 8))
+ end),
+ size = s * 1024,
+ type = "swap"
+ }
+ end
+ end
+
+ swaps:close()
+ end
+
return rv
else
return { error = "Unable to execute block utility" }